package importexport;

import java.util.Vector;

public class Event {
	private String start;
	private String end;
	private String summary;
	private boolean lesson = false;
	private String warningDate;
	private boolean valid = false;
	private String room;
	private String dayOfWeek;
	private String numberOfWeeks;
	private String course;
	
	public Event(Vector<String> lines) {
		
		for (int i = 0; i < lines.size();i++) {
			String line = lines.get(i);
			if (line == null) {
				return;
			}
			if (line.equals("END:VEVENT")) {
				if (!((start == null) | (end == null) | (summary == null))) {
					valid = true;
					if (warningDate == null) {
						warningDate = start;
					}
					return;
				}
			}
			else if (line.startsWith("DTSTART:")) {
				handleStart(line.substring(8));
			}
			else if (line.startsWith("DTEND:")) {
				handleEnd(line.substring(6));
			}
			else if (line.startsWith("SUMMARY:")) {
				handleSummary(line.substring(8));
			}
			else if (line.equals("BEGIN:VALARM")) {
				while (!line.equals("END:VALARM")) {
					if (line.startsWith("TRIGGER:")) {
						handleTrigger(line.substring(8));
					}
					i++;
					line = lines.get(i);
				}
			}
		}
	}
	
	private void handleStart(String line) {
		start = line;
	}
	
	private void handleEnd(String line) {
		end = line;
	}
	
	private void handleSummary(String line) {
		summary = line;
	}
	
	private void handleTrigger(String line) {
		warningDate = line;
	}
	
	public boolean isValid() {
		return valid;
	}
	
	public String getStart() {
		return start;
	}
	
	public String getEnd() {
		return end;
	}
	
	public String getSummary() {
		return summary;
	}
	
	public boolean getLesson() {
		return lesson;
	}
	
	public void setLesson(boolean bool) {
		lesson = bool;
	}
	
	public String getWarningDate() {
		return warningDate;
	}
	
	public String getRoom() {
		return room;
	}
	
	public void setRoom(String room) {
		this.room = room;
	}
	
	public String getDayOfWeek() {
		return dayOfWeek;
	}
	
	public void setDayOfWeek(String day) {
		dayOfWeek = day;
	}
	
	public String getNumberOfWeeks() {
		return numberOfWeeks;
	}
	
	public void setNumberOfWeeks(String nr) {
		numberOfWeeks = nr;
	}
	
	public String getCourse() {
		return course;
	}
	
	public void setCourse(String course) {
		this.course = course;
	}
	
}
